<?php

namespace App\Services\GameTool;

use App\Repositories\GameTool\ChatLogRepository;
use Cache;

class ChatLogService
{
    public function __construct(ChatLogRepository $chatLogRepository)
    {
        $this->chatLogRepository = $chatLogRepository;
    }

    //获取全部的 聊天记录
    public function getAllChatLog($request)
    {
        return $this->chatLogRepository->getAllChatLog($request);
    }

    /**
     * 获取所有    聊天频道
     */
    public function getChatChannelTypes()
    {
        $type = [];
        $gameID = session('game_id');
        $key = "game_id_{$gameID}_chat_channel_type";

        if (Cache::has($key)) {
            $data = Cache::get($key);
        } else {
            $data = $this->chatLogRepository->getChatChannelTypes();
            Cache::put($key, $data, env('CACHE_EXPIRE_TIME', 10));
        }
        return $data;
    }
}